package com.qf.fmall2203.order.controller;

import com.qf.fmall2203.order.entity.Orders;
import com.qf.fmall2203.order.service.IOrdersService;
import com.qf.fmall2203.utils.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 订单  前端控制器
 * </p>
 *
 * @author dongjl
 * @since 2023-02-17
 */
@RestController
@RequestMapping("/order")
@CrossOrigin
@Slf4j
public class OrdersController {

    @Autowired
    IOrdersService ordersService;

    /**
     * 返回订单支付 状态接口
     */

    @GetMapping("/status/{oid}")
    public ResultVo status(@PathVariable("oid") String oid){

        // 查询订单支付状态

        // 如果订单支付成功，返回 字符串 2

        return ResultVo.ok(1);
    }


    /**
     * 下单接口
     * @return
     */
    @PostMapping("/add")
    public ResultVo add(Integer[] cids,@RequestBody Orders orders){

        Map<String,Object> data = ordersService.add(cids,orders);

        return ResultVo.ok(data);
    }

}
